package com.me.libgdx_test;

public class Point {
	public int x,y;
	Point(){
		x=0;
		y=0;
	}
	Point(int x, int y){
		this.x=x;
		this.y=y;
	}
	Point(Point p){
		this.x = p.x;
		this.y = p.y;
	}
	public void multiply(int x,int y){
		this.x *= x;
		this.y *= y;
	}
	public void multiply(Point p){
		this.x *= p.x;
		this.y *= p.y;
	}
	public void add(Point p){
		this.x += p.x;
		this.y += p.y;
	}
	public void add(int x,int y){
		this.x += x;
		this.y += y;
	}
	public void move(Point p){
		this.x = p.x;
		this.y = p.y;
	}
	public void move(int x,int y){
		this.x = x;
		this.y = y;
	}
	public boolean next_to(Point p){
		if((p.x-1==x && p.y==y) || (p.x+1==x && p.y==y) || (p.x==x && p.y-1==y) || (p.x==x && p.y+1==y)){
			return true;
		}
		return false;
	}
	public boolean next_to(int x, int y){
		if((x-1==this.x && y==this.y) || (x+1==this.x && y==this.y) || (x==this.x && y-1==this.y) || (x==this.x && y+1==this.y)){
			return true;
		}
		return false;
	}
	@Override
	  public boolean equals(Object v) {
        boolean retVal = false;

        if (v instanceof Point){
        	Point ptr = (Point) v;
            retVal = ptr.x == this.x && ptr.y == this.y;
        }

        return retVal;
	}

    @Override
    public int hashCode() {
    	
    	int hash = 7; // !!!

    	//integers cannot be null
    	hash = 17 * hash + x;
        hash = 17 * hash + y;

        return hash;
    }
}
